package com.xinfu.newproject.adapter.my_provider;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.xinfu.newproject.R;
import com.xinfu.newproject.contants.Contants;
import com.xinfu.newproject.entity.NormalMultipleEntity;
import com.xinfu.newproject.adapter.home_adapter.HomeAdapter;
import com.xinfu.newproject.bean.home.HomeAdapterBean;
import com.xinfu.newproject.presenter.HomeAdapterPresenter;
import com.xinfu.newproject.view.HomeAdapterView;

import java.util.ArrayList;
import java.util.List;

/**
 * https://github.com/chaychan
 * @author ChayChan
 * @description: Text Img ItemProvider
 * @date 2018/3/30  11:39
 */
public class UserTwoProvider extends BaseItemProvider<NormalMultipleEntity,BaseViewHolder> implements HomeAdapterView {

    private RecyclerView recyclerView;
    private HomeAdapter homeAdapter;
    private HomeAdapterPresenter homeAdapterPresenter;

    @Override
    public int viewType() {
        return MyMultipleItemRvAdapter.TYPE_USER_TWO;
    }

    @Override
    public int layout() {
        return R.layout.item_user_two;
    }

    @Override
    public void convert(BaseViewHolder helper, NormalMultipleEntity data, int position) {
        recyclerView = helper.getView(R.id.item_user_two_rv);
        homeAdapterPresenter = new HomeAdapterPresenter(this);
        homeAdapterPresenter.onfresh(true, Contants.USERTWODATA);
//        helper.setText(R.id.tv, data.content);
//        if (position % 2 == 0) {
//            helper.setImageResource(R.id.iv, R.mipmap.ic_launcher);
//        }else{
//            helper.setImageResource(R.id.iv, R.mipmap.ic_launcher);
//        }
    }

    @Override
    public void onClick(BaseViewHolder helper, NormalMultipleEntity data, int position) {
//        Toast.makeText(mContext, "click", Toast.LENGTH_SHORT).show();
    }

    @Override
    public boolean onLongClick(BaseViewHolder helper, NormalMultipleEntity data, int position) {
//        Toast.makeText(mContext, "longClick", Toast.LENGTH_SHORT).show();
        return true;
    }

    @Override
    public void success(List<HomeAdapterBean> homeAdapterBean) {

        List<Integer> typeList=new ArrayList<>();
        typeList.add(2);
        homeAdapter = new HomeAdapter(mContext,homeAdapterBean,typeList);
        recyclerView.setLayoutManager(new GridLayoutManager(mContext,4));
        recyclerView.setAdapter(homeAdapter);
    }

    @Override
    public void fasle(Exception e) {

    }

    @Override
    public void getData(HomeAdapterBean homeAdapterBean) {

    }
}
